import java.util.Scanner;

public class Demo1 {
    static int n,r,w[];
    static boolean box[];
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        n=in.nextInt(); r=in.nextInt();
        box=new boolean[n+1];
        w=new int[r+1];
        dfs(1);
    }
    static void dfs(int x)
    {
        if(x>r) //满r位 输出
        {
            for(int i=1;i<=r;i++)
                System.out.printf("%3d",w[i]);
            System.out.println();
            return;
        }
        for(int i=1;i<=n;i++)
        {
            if(box[i])  //如果该数字已经在组合中
                continue;
            if(x>1&&w[x-1]>i)
            continue;
            box[i]=true;
            w[x]=i;
            dfs(x+1);
            box[i]=false;
        }
    }
}
